/*
 * baseOP.h
 *
 *  Created on: 30-Oct-2011
 *      Author: willion
 */

#ifndef BASEOP_H_
#define BASEOP_H_

class baseOP
{
public:

	//constructor and destructor
	//default seed is 111
	baseOP(int l_dim, int m_dim, int n_dim, int looptime);
	virtual ~baseOP();

	//basic matrix multiplication
	//result = left*right
	//left size: l_dim * m_dim, right size: m_dim * n_dim
	virtual void multi_matrix(const int** left, const int** right,
			int** result,
			int l_dim, int m_dim, int n_dim);

	//randomly generate the matrix
	void init_matrix(int** &matrix, int l_dim, int m_dim);

	void fill_matrix(int** &matrix, int l_dim, int m_dim, bool rd_gen = true);

	//destroy the matrix and recycle the memory
	void destroy_matrix(int** matrix, int l_dim, int m_dim);

	//print out the matrix
	virtual void display_matrix(int token);

	//just a shadow, for derived class use
	virtual void go(int multi_method);


	void display_time(struct timespec start, struct timespec end);


	void transpose_matrix(int** &matrix, int l_dim, int m_dim);

	//reference to _left, _right and _resutl
	static const int LEFT = 1;
	static const int RIGHT = 2;
	static const int RESULT = 3;

protected:
	//left, right and the result matrices
	//left size: l_dim * m_dim, right size: m_dim * n_dim
	//result size: l_dim * n_dim
	int** _left;
	int** _right;
	int** _result;

	int _l_dim;
	int _m_dim;
	int _n_dim;

	//random seed, used to generate random matrix
	int _seed;

	int _looptime;
};

//different partition method
//implement row-column(NAIVE), row-row(ROW), block-block(BLOCK)
static const int NAIVE = 1;
static const int ROW = 2;
static const int BLOCK = 3;

//different multi method
static const int BASE_IMP = 1;
static const int ADV_IMP = 2;

#endif /* BASEOP_H_ */
